const {UserModel, PlayerModel, PlayerDailyTrainingModel} = require("./model");
const md5 = require('blueimp-md5');

async function init() {
  let data;

  await UserModel.collection.drop();
  console.log(2);

  const user = new UserModel({
    username: 'admin',
    password: md5('password')
  });
  data = await user.save();
  console.log(data);

  const playerModel = new PlayerModel({
    userId: data.id
  });
  data = await playerModel.save();
  console.log(data);

  [60, 72, 79].forEach(async item => {
    console.log(await (new PlayerDailyTrainingModel({
      playerId: data.id,
      morningPulse: item
    })).save());
  })
}

init().catch(err => {
  console.log(err);
});
